
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yt_devops/components/log_utils.dart';
import 'package:yt_devops/pages/operation_matainance/widgets/alarm_task_tab.dart';
import 'package:yt_devops/pages/site/site_setting/siet_elec_price_setting/site_mains_elec_detail/keep_aliver_wrapper.dart';
import 'home_site_statistics_controller.dart';

class HomeSiteStatisticsPage extends GetView<HomeSiteStatisticsController> {
  final List<Widget> homeTabviewChildren;
  final bool firstIsStatic;

  ///第一个tab是不是统计
  const HomeSiteStatisticsPage(this.homeTabviewChildren,
      {this.firstIsStatic = false, Key? key})
      : super(key: key);
  @override
  Widget build(BuildContext context) {
    return GetBuilder<HomeSiteStatisticsController>(
        init: controller,
        didUpdateWidget: (GetBuilder oldWidget, state) {
          Log.d('HomeSiteStatisticsPage==didUpdateWidget');
        },
        initState: (state) {
          Log.d('HomeSiteStatisticsPage==didUpdateWidget' + homeTabviewChildren.length.toString());
          controller.homeTabviewChildren = homeTabviewChildren;
          controller.firstIsStatic = firstIsStatic;
          controller.initData();
        },
        builder: (controller) {
          return Stack(
            children: [
              Scaffold(
                body: TabBarView(
                    physics: const NeverScrollableScrollPhysics(), //禁止滑动
                    controller: controller.tabController,
                    children: homeTabviewChildren),
              ),
              KeepAliveWrapper(Container(
                // color: Colors.grey,
                margin: EdgeInsets.only(
                    left: 16.w, top: ScreenUtil().statusBarHeight - 4),
                child: AlarmTaskTab(
                  controller.selectedIndex,
                  (int index) {
                    controller.selectedIndex = index;
                    controller.tabController?.animateTo(index);
                    controller.update();
                  },
                  firstTitle:controller.firstTabTitle,
                  secondTitle: controller.secondTabTitle,
                  textColor: Colors.white,
                  unSelectedTextColor: Colors.white.withOpacity(0.65),
                ),
              )),
            ],
          );
        });
  }
}
